using System;
using System.Collections.Generic;
using System.Text;

namespace Bule.Malbilden.Domain
{
    public class FoodProduct : IEatable
    {
        public FoodProduct() : this("") { }
        public FoodProduct(string name) : this(name, new NutritionData()) { }
        public FoodProduct(string name, NutritionData nutritionalValue) : this(name, "portion", 100, nutritionalValue) { }
        public FoodProduct(string name, string portionName, double portionSize, NutritionData nutritionPerHundredGrams)
        {
            Name = name;
            PortionName = portionName;
            PortionSize = portionSize;
            NutritionPerHundredGrams = nutritionPerHundredGrams;
        }

        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual string PortionName { get; set; }
        public virtual double PortionSize { get; set; }
        public virtual NutritionData NutritionPerHundredGrams { get; private set; }

        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
                return false;

            FoodProduct right = (FoodProduct)obj;

            return right.Name == this.Name &&
                right.PortionName == this.PortionName &&
                right.PortionSize == this.PortionSize &&
                right.NutritionPerHundredGrams == this.NutritionPerHundredGrams;
        }

        public override int GetHashCode()
        {
            return Name.GetHashCode();
        }

        public override string ToString()
        {
            return "Name: " + Name + ", PortionName: " + PortionName + ", PortionSize: " + PortionSize;
        }
    }
}
